pic_path = '/home/dht/odaiba.jpg'

import cv2
# import tkinter as tk
#
# window = tk.Tk()

# def get_video():
#     import numpy as np
#     pic_path = 'sister.mp4'
#     cv2.namedWindow('abc', 0)
#     cv2.resizeWindow('abc',400,300)
#     cap = cv2.VideoCapture(pic_path)
#     index = 0
#     while True:
#         # get a frame
#         ret, frame = cap.read()
#         # show a frame
#         if frame is None:
#             break
#         if index == 100:
#             cv2.destroyAllWindows()
#         cv2.imshow("abc", frame)
#         if cv2.waitKey(16) & 0xFF == ord('q'):
#             break
#         index += 1
#     cap.release()
#
#
# window.after(1, get_video)
# window.mainloop()
# cv2.destroyAllWindows()

import cv2
import tkinter as tk
from PIL import ImageTk,Image




def get_video():
    pic_path = 'sister.mp4'

    cap = cv2.VideoCapture(pic_path)
    index = 0
    while 1:
        ret, frame = cap.read()
        print(frame)
        if frame is None:
            print('播放结束')
            break

        cv2.imwrite('new_img_%s.png' % str(index), frame)
        img = Image.open('new_img_%s.png' % str(index))
        resize_img = img.resize((750, 450))
        resize_img.save('resizeimg_%s.png' % str(index))

        window.after(1)
        index += 1


    # cap.release()


window = tk.Tk()
val = tk.StringVar()
window.title('显示个图片')
img = Image.open('resizeimg.png')
photo = ImageTk.PhotoImage(img)
tk.Label(window, image=val.get(), height=450, width=750).grid()
window.after(1, get_video)

window.mainloop()